<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="zhcms.admin.*" %> 
<%@ page import="zhcmsPlus.vote.*" %> 
<%@ page import="zhcms.framework.*" %> 
<%@ include file="include/adminhead.jsp" %>
<%
request.setCharacterEncoding("utf-8");
String action=request.getParameter("atcion");
GyUserLoginValidate gycheck=new GyUserLoginValidate();
int ischeck=gycheck.UserLoginValidate(request, response);
if(ischeck==0)
{
		try{
			out.println("<script language='javascript'>alert('对不起！，您还没有登陆');location.href=\"index.jsp\";</script>");
		}
		catch(Exception e){
			e.printStackTrace();
		}
} 

%>
<TABLE width="100%" border=0 align="center" cellPadding=0 cellSpacing=0 class=sortbutton>
	<tr> 
	    <th width="100%" height="22" valign="middle"><a href="?">管理首页</a> | <a href="?atcion=add">新增</a>  </th>
	</tr>
</table>
<br>
<% 
if(action==null || action.length()<=0  || action.equals("main"))
{
String page1=request.getParameter("p");
int pageb;    //存储当前页码
if(page1==null)
   pageb=1;
else 
   pageb=Integer.parseInt(page1);
  
VoteManger gyvote=new VoteManger();

int countnum=gyvote.listcount();
%>
<table width="98%" border="0" cellpadding="0" cellspacing="0" align="center" class="TableBorder">
  <tr valign="middle" align="center" height="22"> 
   	<th width="10%">Id</th>
    <th width="40%">投票主题</th>
    <th width="10%">投票数</th>
    <th width="10%">类型</th>
    <th width="10%">状态</th>
    <th width="20%">操作</th>
  </tr>
<%
if(countnum>0)
{
String lybpages="";
ArrayList<HashMap<String, String>> gyVoteFor;
gyVoteFor=new ArrayList<HashMap<String, String>>();
gyVoteFor=gyvote.getAllList(pageb);
lybpages=gyvote.getPageStr();
for(int i=0;i<gyVoteFor.size();i++)
{
	Map<String,String> gyVoteForinfo=new HashMap<String,String>();
	gyVoteForinfo=gyVoteFor.get(i);
	
	String V_Type="";
	if(gyVoteForinfo.get("V_Type")==null || gyVoteForinfo.get("V_Type").length()<=0)
	{
		V_Type="单选";
	}
	else if(gyVoteForinfo.get("V_Type").equals("1"))
	{
		V_Type="多选";
	}
	else
	{
		V_Type="单选";
	}
	
	String v_Lock="";
	if(gyVoteForinfo.get("V_Type")==null || gyVoteForinfo.get("V_Type").length()<=0)
	{
		V_Type="锁定";
	}
	else if(gyVoteForinfo.get("V_Type").equals("0"))
	{
		V_Type="正常";
	}
	else
	{
		V_Type="锁定";
	}
	
 %>
  <tr valign="middle" bgcolor="#FFFFFF" align="center" height="22"> 
  <td><%=gyVoteForinfo.get("Id")%></td>
    	<td><%=gyVoteForinfo.get("Title")%></td>
    <td align="left">&nbsp;<%=gyVoteForinfo.get("VoteTotal")%></td>
    <td><%=V_Type%></td>
    <td><font color=800000><%=V_Type%></font></td>
    <td><a href="?atcion=add&postid=<%=gyVoteForinfo.get("Id")%>">编辑</a> | <a href="?atcion=del&postid=<%=gyVoteForinfo.get("Id")%>" onclick="{if(confirm('确定删除吗?')){return true;}return false;}">删除</a></td>
  </tr>
<%
}
 %>
  <tr valign="middle" bgcolor="#FFFFFF" align="right">
	<td colspan="6" height="22">&nbsp;<%=lybpages%></td>
  </tr>
 <%
 }
 else
 {
 %> <tr valign="middle" bgcolor="#FFFFFF">
	<td colspan="6" height="22">&nbsp;暂时没有任何信息！</td>
  </tr>
 <%
 } 
 %>
</table>
<%
}
else if(action.equals("add")) 
{

String postid=request.getParameter("postid");

String Title="";
String VoteText="";
String VoteText1="";
String V_Type="";
String v_Lock="";

if(postid==null || postid.length()<=0)
{
	
}
else
{
	VoteManger gyvote=new VoteManger();
	ArrayList<HashMap<String, String>> VoteOne;
	VoteOne=new ArrayList<HashMap<String, String>>();
	VoteOne=gyvote.getOneList(postid);
	if(VoteOne.size()>0)
	{
		Map<String,String> iiFriendLinkinfo=new HashMap<String,String>();
		iiFriendLinkinfo=VoteOne.get(0);
		Title=iiFriendLinkinfo.get("Title");
		VoteText=iiFriendLinkinfo.get("VoteText");
		V_Type=iiFriendLinkinfo.get("V_Type");
		v_Lock=iiFriendLinkinfo.get("v_Lock");
		GyReplace r = new GyReplace();
		VoteText = r.replace(VoteText, "|", "\r\n");
	}
	

}

%>
<table width="80%" border="0" cellpadding="0" cellspacing="0" class=TableBorder align="center">
  <form name=a1  method="post" action="/zhcmsPlus!vote!VoteManger(save).do?postid=<%=postid%>">
    <tr align="center" valign="middle"> 
      <th colspan="2" height="22">投票管理</th>
    </tr>
    <tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="25%" align="center">标题</td>
      <td align="left">&nbsp;<input type="text" name="Title" size="40" value="<%=Title%>"></td>
    </tr>
    <tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="20%" align="center">投票项目</td>
      <td align="left">&nbsp;<br><br><LI>每行一个投票项目，最多<B>10</B>个 <LI>超过自动作废，空行自动过滤
      <BR><BR>
      <input type="radio" name="V_Type" value="0" <%
        						if(V_Type.equals("0"))
        									{
        										out.println(" checked ");
        									}
        		 %>>单选投票&nbsp;
      <input type="radio" name="V_Type" value="1" <%
        						if(V_Type.equals("1"))
        									{
        										out.println(" checked ");
        									}
        		 %>>多选投票</td>
    </tr>
    <tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="20%" align="center"> </td>
      <td align="left">&nbsp;<textarea name="VoteText" wrap="VIRTUAL" rows="10" cols="40"><%=VoteText%></textarea><br>&nbsp;<a href="javascript:change(document.all.vote,-20)"><img src="images/minus.gif" border=0 title="缩小文本框"></a>&nbsp;&nbsp;<a href="javascript:change(document.all.vote,20)"><img src="images/plus.gif" border=0 title="放大文本框"></a></td>
    </tr>
    <tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="20%" align="center">是否锁定</td>
      <td align="left">&nbsp;<input type="radio" name="v_Lock" value="0" <%
        						if(V_Type.equals("0"))
        									{
        										out.println(" checked ");
        									}
        		 %>>正常&nbsp;
      <input type="radio" name="v_Lock" value="1" <%
        						if(V_Type.equals("1"))
        									{
        										out.println(" checked ");
        									}
        		 %>>锁定</td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td align="center" valign="middle" colspan="2"><input type="submit" name="Submit" value="更新">&nbsp;<input type="reset" name="Submit2" value="重置"></td>
    </tr>
  </form>
</table>
<%
}
%>
<%@ include file="include/adminfoot.jsp" %>

